package com.yunhai.recipe.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yunhai.common.dto.PaginationVo;
import com.yunhai.common.dto.Ret;
import com.yunhai.model.entity.fms.FmsMaterialPrecisionTemplateEntity;
import com.yunhai.model.vo.fms.FmsMaterialPrecisionTemplateQuery;
import com.yunhai.model.vo.fms.FmsMaterialPrecisionTemplateVo;
import com.yunhai.recipe.service.FmsMaterialPrecisionTemplateService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/materialPrecisionTemplate")
public class FmsMaterialPrecisionTemplateController {

    @Resource
    private FmsMaterialPrecisionTemplateService fmsMaterialPrecisionTemplateService;


    /**
     * 获取 FmsMaterialPrecisionTemplate 分页列表
     */
    @GetMapping("/pagination")
    public Ret getFmsMaterialPrecisionTemplatePagination(PaginationVo paginationVo, FmsMaterialPrecisionTemplateQuery fmsMaterialPrecisionTemplateQuery ) throws Exception {
        IPage page = fmsMaterialPrecisionTemplateService.getFmsMaterialPrecisionTemplatePagination(paginationVo, fmsMaterialPrecisionTemplateQuery );
        return Ret.toPage(page);
    }


    /**
     * 获取 FmsMaterialPrecisionTemplate 所有数据
     */
    @GetMapping("/all")
    public Ret getFmsMaterialPrecisionTemplateAllList( FmsMaterialPrecisionTemplateQuery fmsMaterialPrecisionTemplateQuery ) throws Exception {
        List<FmsMaterialPrecisionTemplateEntity> list = fmsMaterialPrecisionTemplateService.getFmsMaterialPrecisionTemplateAllList( fmsMaterialPrecisionTemplateQuery );
        return Ret.ok(list);
    }



    /**
     * 获取 FmsMaterialPrecisionTemplate 详情
    */
   @GetMapping("/{id}")
   public Ret getFmsMaterialPrecisionTemplateDetail(@PathVariable Long id) throws Exception {

       FmsMaterialPrecisionTemplateEntity fmsMaterialPrecisionTemplate = fmsMaterialPrecisionTemplateService.getFmsMaterialPrecisionTemplateDetail(id);
       return Ret.ok(fmsMaterialPrecisionTemplate);
   }


    /**
     * 新增 FmsMaterialPrecisionTemplate
     * */
    @PostMapping("")
    public Ret addFmsMaterialPrecisionTemplate(@RequestBody FmsMaterialPrecisionTemplateVo fmsMaterialPrecisionTemplateVo) throws Exception {

        fmsMaterialPrecisionTemplateService.addFmsMaterialPrecisionTemplate(fmsMaterialPrecisionTemplateVo);
        return Ret.ok();
    }


    /**
     * 更新 FmsMaterialPrecisionTemplate
     * */
    @PutMapping("")
    public Ret updateFmsMaterialPrecisionTemplate(@RequestBody FmsMaterialPrecisionTemplateVo fmsMaterialPrecisionTemplateVo) throws Exception {

        fmsMaterialPrecisionTemplateService.updateFmsMaterialPrecisionTemplate(fmsMaterialPrecisionTemplateVo);
        return Ret.ok();
    }


    /**
     * 删除 FmsMaterialPrecisionTemplate
     * */
    @PostMapping("/batchRemove")
    public Ret batchRemoveFmsMaterialPrecisionTemplate( @RequestBody List<Long> ids ) throws Exception {

        fmsMaterialPrecisionTemplateService.batchRemoveFmsMaterialPrecisionTemplate(ids);
        return Ret.ok();
    }
}

  